

var NodeRSA = require('node-rsa');
var key = new NodeRSA({b: 512}); //生成新的512位长度密钥
// console.log('key---->',key);
var publicDer = key.exportKey('public');
var privateDer = key.exportKey('private');
console.log('公钥:',publicDer);
console.log('私钥:',privateDer);
var text = 'lmontree'; // 加密前数据
var encrypted = key.encrypt(text, 'base64');  // 加密后数据
console.log('encrypted: ', encrypted);
var decrypted = key.decrypt(encrypted, 'utf8'); // 解密后数据
console.log('decrypted: ', decrypted);



// https://blog.csdn.net/qq_39791705/article/details/79567410